package com.itheima.exerciseTest.test60_69;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

public class Test66 {
    public static void main(String[] args) throws InterruptedException {
        // 创建ConcurrentHashMap集合对象
        HashMap<Integer,Integer> chm = new HashMap<>();

        // 创建线程
        for (int i = 0; i < 50; i++) {
            int finalI = i;
            new Thread(()->{
                chm.put(finalI, finalI);
            }).start();
        }

        for (int i = 50; i < 101; i++) {
            int finalI = i;
            new Thread(()->{
                chm.put(finalI, finalI);
            }).start();
        }

        Thread.sleep(1);

        for (int i = 0; i < 101; i++) {
            Integer value = chm.get(i);
            System.out.println(value);
        }
        // System.out.println(chm);
    }
}
